#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>


void rotate(int* nums, int numsSize, int k) {
	k = k % numsSize;

	int* arr = (int*)malloc(numsSize * sizeof(int));
	if (arr == NULL)
	{
		perror("malloc fail");
	}
	int j = numsSize - k;
	for (int i = 0; i < k; i++)
		arr[j++] = nums[i];
	j = 0;
	for (int i = k; i < numsSize; i++)
		arr[j++] = *(nums + i);
	for (int i = 0; i < numsSize; i++)
	{
		*(nums + i) = arr[i];
	}

}
int main()
{
	int a[4] = { -1,-100,3,99 };
	rotate(a, 4, 2);
	for (int i = 0; i < 4; i++)
	{
		printf("%d ", a[i]);
	}




}